#ifndef NNENGINE_
#define NNENGINE_

#include <cstdlib> 
#include <cstdio>
#include <ctime> 
#include <cmath>
#include "bmpinterface.h"
#include "ngfinterf.h"
#include "message.h"
#include "params.h"

class NeuralNetworkEngine {
	
private:
	Parameters*	parameters;
	Message*	message;
	
	BitmapInterface* 				bmp; // bitmap file
	NeuralGraphicsFileInterface* 	ngf; // neural network file
	
	int image_height, image_width;
	int input_height, input_width; 		// size of the input neurons
	int hidden_size;					// size of the hidden neurons 
										// note: no height, width, they're plain
	int output_height, output_width;	// size of the output neurons
	
	int samples_count_h, samples_count_w;
										// number of samples that will be given
										// to the neural network :D
	int color;
	
	
	double * 	hidden_weights;
	double * 	hidden_weights_feedback;
	double * 	hidden_data;
	
	double *	output_weights;
	double *	output_weights_feedback;
	double *	output_data;
	
	double * 	current_sample;
	
	int has_errors;
	
	// functions:
	void allocateHiddenWeights();
	void allocateOutputWeights();
	void allocateHiddenWeightsFeedback();
	void allocateOutputWeightsFeedback();
	void allocateHiddenData();
	void allocateOutputData();
	void allocateCurrentSampleSpace();
	void freeAll();
	
public:
	NeuralNetworkEngine(Parameters* params, Message* msg);
	~NeuralNetworkEngine();
	int transformBMPintoNGF();
	int transformNDFintoBMP();
	int hasErrors();
};


#endif /*NNENGINE_*/
